import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		uuid: "",
		token: "",
		hasLogin: false,
		screenWidth: 960,
		totalEvCount: 100,
		projectsInfo: {},
		propertiesData: {
			"hcho": 0.00,
			"temp": 25.32,
			"pm25": 2.00,
			"pm1": 0.00,
			"co2": 0.00,
			"pm10": 2.00,
			"humidity": 65.38,
			"atm": 0.00
		},
		fanMapArray: [],
		configDeviceIds: []
	},
	mutations: {
		login(state, data) {
			state.hasLogin = true;
			state.uuid = data.uuid;
			state.token = data.token;
			state.projectsInfo = data.projectsInfo;
		},
		logout(state) {
			state.hasLogin = false;
			state.uuid = "";
			state.token = "";
		},
		setTotalEvCount(state, data) {
			state.totalEvCount = data;
		},
		setProjectsInfo(state, data) {
			state.projectsInfo = data;
		},
		setProperties(state, data) {
			state.propertiesData = data;
		},
		setFanMapArray(state, data) {
			state.fanMapArray = data;
		},
		setConfigDeviceIds(state, data) {
			state.configDeviceIds = data;
		},
		setToken(state, data) {
			state.hasLogin = true;
			state.token = data;
		},
		setScreenWidth(state, data) {
			state.screenWidth = data;
		},
	},
	getters: {
		currentState(state) {
			return state.hasLogin;
		},
		getJwtToken(state) {
			return state.token;
		}
	},
	actions: {
		// lazy loading openid
	}
})
